<?php
session_start();

include 'dbconnect.php';

  // Check connection
if (mysqli_connect_errno())
  {
  //echo "alert'Failed to connect to MySQL: ' . mysqli_connect_error()";
  }
$number = $_SESSION['number'];
if ($number[0] == "+")
	$number[0] = "_";
$table = "SELECT * FROM contacts".$number." order by contactName";
$result = mysqli_query($con, $table);
$html1 = "";
$html2 = "";
while($row = mysqli_fetch_array($result))
  {
	$html2 = $html2."<tr><td><div class='woogie-contact' onclick='addTab($row[contactId], $row[contactNumber])'>".
				"<div class='woogie-contact-left'>".
					"<img src='images/user_sms.png'/>".
				"</div>".
				"<div class='woogie-contact-right'>";
				
	$count = 0;
	
	if ($count == 0){
		$html2 = $html2."<div class='woogie-contact-right-new'>".
						"<img src='images/messages.png'/>".
					"</div>";
	}
	
	$html2 = $html2."<div class='woogie-contact-name'>".$row['contactName']."</div>".
					"<div class='woogie-contact-number'>".$row['contactNumber']."</div>".
				"</div>".
			"</div></td></tr>";
	if ($row['view'] == 1)
		$html1 = $html1 . "<div class='tab' onclick='getSMSFrom($row[contactId])' id='$row[contactNumber]' title='".$row['contactName']." (".$row['contactNumber'].")'><div>".$row['contactName']."</div><img onclick='removeTab($row[contactId])' src='images/delete_red.png' title='Remove tab'/></div>";
  }
 echo $html1."%".$html2; 
mysqli_close($con);
?>
